package test.test_7_23;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/*
假设有一个字符串"abcqweracb"
在不改变前后顺序的前提下去除重复的字符得到"abcqwer"
(结合使用ArrayList)
 */
public class Demo01 {
    public static void main(String[] args) {
        String str = "abcqweracb";
        List<String> list1 = new ArrayList<>();
        List<String> list2 = new ArrayList<>();

        for(int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            String str1 = Character.toString(c);
            list1.add(str1);
        }
        Iterator<String> it = list1.iterator();
        while(it.hasNext()) {
            String s = it.next();
            if(!list2.contains(s)) {
                list2.add(s);
            }
        }
        System.out.println(list2);

    }
}
